/**
 * react 解析HTML
 * dangerouslySetInnerHTML={{__html: this.state.list.content}}
 */
import React, { Component } from 'react';
import {Link } from "react-router-dom";
import '../assets/css/basic.css';
import '../assets/css/pcontent.css';
const axios = require('axios');
 
class Pcontent extends Component {
    constructor(props) {
        super(props);
        this.state = { 
            list: '',
            id: '',
            domin: 'http://a.itying.com/'
         };
    }
    componentWillMount() {
        // id
        this.id = this.props.match.params.id;
        this.requestData();
    }
    requestData =() => {
        let api = `${this.state.domin}api/productcontent?id=${this.id}`;

        axios.get(api).then(res => {
            console.log(res.data.result)
            this.setState({
                list: res.data.result[0]
            })
        })
    }
    render() {
        return (
            <div>
                <div className="back"><Link to='/'>返回</Link></div>
                <div className="p_content">		
                    <div className="p_info">				
                        <img src={`${this.state.domin}${this.state.list.img_url}`}/>				
                        <h2>{this.state.list.title}</h2>				
                        <p className="price">{this.state.list.price}/份</p>
                    </div>
                    <div className="p_detial">
                        <h3>
                            商品详情					
                        </h3>
                        <div className="p_content"> 
                            <img src={`${this.state.domin}${this.state.list.img_url}`}/>			
                            <br />
                            <p dangerouslySetInnerHTML={{__html: this.state.list.content}}>
                            </p>
                            <br />
                        </div>
                    </div>
                </div>
		        {/* <footer className="pfooter">
                    <div className="cart">				
                        <strong>数量:</strong>
                        <div className="cart_num">
                        <div className="input_left">-</div>
                        <div className="input_center">
                            <input type="text"  readonly="readonly" value="1" name="num" id="num" />
                        </div>
                        <div className="input_right">+</div>				      
                        </div>								
                    </div>
                    <button className="addcart">加入购物车</button>			
		        </footer> */}
            </div>
        );
    }
}

export default Pcontent;